<?php

namespace app\admin\model\kefu;

use think\Model;

/**
 * Message
 */
class Message extends Model
{
    // 表名
    protected $name = 'kefu_message';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;
    protected $updateTime         = false;

    protected $type = [
        'extend' => 'array',
    ];

    public function session(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\kefu\Session::class, 'session_id', 'id');
    }

    public function sender(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\kefu\User::class, 'sender_id', 'id');
    }

    public function recipient(): \think\model\relation\BelongsTo
    {
        return $this->belongsTo(\app\admin\model\kefu\User::class, 'recipient_id', 'id');
    }
}